<?php

/**
 * 微信事件回复模型管理logic
 */

namespace Member\Logic;

class TextNewsLogic extends CommonLogic {

	/**
	 * 获取全部的模块和图文消息内容
	 */
	public function moudles_news(){
		
		//获取全部的模块信息
		$moudle = D('Module','Logic');
		$modules = $moudle->allLists();
		foreach ($modules as $k => $v){
			$v['url'] = $v['name'];
			if($v['name']=='vote'){
				unset($modules[$k]);
			}
			if($v['name']=='reserve'){
				unset($modules[$k]);
			}
		}
		//获取全部的图文消息
		$newsmsgLogic = D('Newsmsg','Logic');
		$newsmsgs = $newsmsgLogic->allLists();
		
		$data = array(
		    'modules'=>$modules,
			'newsmsgs'=>$newsmsgs,
		);
		return $data;
	}
	
	/**
	 * 根据选择的信息返回需要保存到数据库中的信息
	 */
	public function savedata($name){
		$newsmsgLogic = D('Newsmsg','Logic');
		//如果是单图文消息内容
		if(intval($name) > 0){
			$newmsg = $newsmsgLogic->detail(intval($name));
			 
		}else{
			//如果是模块内容信息
			$newmsg = $newsmsgLogic->where(array('relation'=>$name,'uid'=>UID))->find();
			//logs($newsmsgLogic->getLastSql());
			$newmsg['msgtype'] = $name;
		}
		$data = array(
		    'msgtype'=>$newmsg['msgtype'],
		    'msgid'=>$newmsg['id'],
		);
		
		return $data;
			
	}
	/* (non-PHPdoc)
	 * @see \Member\Logic\CommonLogic::autoSave()
	 */
	public function autoSave($id = 0) {
		// TODO Auto-generated method stub
		
	}

	/* (non-PHPdoc)
	 * @see \Member\Logic\CommonLogic::update()
	 */
	public function update($id = 0) {
		// TODO Auto-generated method stub
		
	}

	
	
}